package io.renren.modules.app.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import io.renren.modules.app.annotation.Login;
import io.renren.modules.app.entity.FslipEntity;
import io.renren.modules.app.entity.UserEntity;
import io.renren.modules.app.service.FslipService;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 纸条，消息列表
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-10-31 09:06:55
 */
@RestController
@RequestMapping("app/fslip")
public class AppFslipController {

    @Autowired
    private FslipService fslipService;



    @Login
    @PostMapping("/getfslipList")
    @ApiOperation("获取消息列表")
    public R getfslipList(@RequestBody FslipEntity fslfip){
        List<FslipEntity> fslipList = fslipService.getFslipList(fslfip);
        return R.ok().put("fslipList", fslipList);
    }
    //添加
    @RequestMapping("/addFslip")
    @ApiOperation("添加纸条并返回一条")
    //@RequiresPermissions("generator:fslip:list")
    public R addFslip(@RequestBody FslipEntity fslfip){
        FslipEntity fslip= fslipService.addFslip(fslfip);

        return R.ok().put("fslip", fslip);
    }
    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("generator:fslip:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = fslipService.queryPage(params);

        return R.ok().put("page", page);
    }



    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("generator:fslip:info")
    public R info(@PathVariable("id") Long id){
		FslipEntity fslip = fslipService.getById(id);

        return R.ok().put("fslip", fslip);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("generator:fslip:save")
    public R save(@RequestBody FslipEntity fslip){
		fslipService.save(fslip);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("generator:fslip:update")
    public R update(@RequestBody FslipEntity fslip){
		fslipService.updateById(fslip);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("generator:fslip:delete")
    public R delete(@RequestBody Long[] ids){
		fslipService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
